package com.tim.framework.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.dao.DataAccessException;

import com.tim.framework.common.PageList;
import com.tim.framework.common.PageProperty;

/**
 * @author kim
 * 
 * 提供单表数据查询保存的基本方�?
 */
public interface BaseService<T> {
	public abstract T getModel(Serializable id);

	public abstract Serializable create(T model) throws DataAccessException;

	public abstract void update(T model) throws DataAccessException;

	public abstract void delete(T model) throws DataAccessException;

	public abstract int getAllCount() throws DataAccessException;

	public abstract int getCount(PageProperty pp) throws DataAccessException;

	public abstract List<T> getList(PageProperty pp) throws DataAccessException;

	public abstract PageList<T> getPageList(PageProperty pp)
			throws DataAccessException;

	/**
	 * 执行hql查询语句.
	 * 
	 * @param sql
	 *            hql语句.
	 * @param params
	 *            参数列表.
	 */
	public List<Object> executeHqlQuery(String sql, List<Object> params);

	/**
	 * 执行update或delete的hql语句.
	 * 
	 * @param String
	 *            执行语句的模式update或delete
	 * @param String
	 *            update或delete之后的sql语句
	 * @param List
	 *            执行参数
	 * @return Integer 影响的行数.
	 */
	public abstract int executeUpdate(String model, String sql,
			List<Object> params);
}
